package com.xiaofeng.api.common;

import lombok.Getter;

/**
 * Created with IntelliJ IDEA
 *
 * @Author: chc
 * @Date: 2024/01/23/21:36
 * @Description: 自定义返回状态码枚举
 */
@Getter
public enum ResultCodeEnum {

    SUCCESS(200,"成功"),
    FAIL(500,"失败");

    public int code;

    public String desc;

    ResultCodeEnum(int code,String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ResultCodeEnum getByCode(int codeVal){
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()){
            if (resultCodeEnum.code == codeVal){
                return resultCodeEnum;
            }
        }
        return null;
    }
}
